scroll
animates the scroll top/left position of an element (in 340 bytes)
note: you may need to polyfill requestAnimationFrame
in older browsers
install
npm install scroll
use
var scroll = require('scroll')
var page = require('scroll-doc')()
var ease = require('ease-component')
scroll.left(page, 200)
scroll.top(page, 200, function (err, scrollTop) {
console.log(err)
console.log(scrollTop)
})
scroll.left(page, 200, { ease: ease.inBounce })
scroll.left(page, 200, { duration: 1000 }, function (err, scrollLeft) {
})
var options = { duration: 1000 }
var cancel = scroll.top(page, 200, options, function (err, scrollTop) {
console.log(err.message)
page.removeEventListener('wheel', cancel)
})
page.addEventListener('wheel', cancel)
note: the default easing is inOutSine
from component/ease.
obey
MIT